package com.gimi.cloud.jimi.client.service.userInfo.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.gimi.cloud.jimi.client.service.userInfo.LbsDistrictService;
import com.gimi.cloud.jimi.dao.dao.userInfo.LbsDistrictDao;
import com.gimi.cloud.jimi.entity.userInfo.LbsDistrict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class LbsDistrictServiceImpl implements LbsDistrictService {
	
	@Autowired
	private LbsDistrictDao lbsDistrictDao;

	@Override
	public Map<String, Long> getDistrictByHashCode(Integer[] hashCodes) {
		Map<String, Long> result = new HashMap<String,Long>();
		if(null != hashCodes && hashCodes.length > 0){
			List<Map<String, Object>> districts = lbsDistrictDao.getDistrictByHashCode(hashCodes);
			if(null != districts && !districts.isEmpty()){
				for (Map<String, Object> map : districts) {
					result.put(""+map.get("hashcode"), Long.valueOf(String.valueOf(map.get("id"))));
				}
			}
		}
		return result;
	}
	
	 @Override
    public void addLbsDistrict(LbsDistrict lbsDistrict) {
       lbsDistrictDao.insertSelective(lbsDistrict);
    }

}
